/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.gui.model;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import program.beans.Bill;

/**
 * TableCellRenderer for ViewBillTable
 * 
 * Responsible: Patrick
 */
public class ViewBillTableRenderer extends JLabel implements TableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

        Bill b = (Bill) value;

        switch (column) {
            case 0:
                setText(b.getBid());
                break;
            case 1:
                setText(b.getComp().getName());
                break;
            case 2:
                setText(b.getBillDate());
                break;
            case 3:
                setText(b.getAllBruttoAmountsFormated());
                break;
            case 4:
                setText(b.getCat().getDescription());
                break;
        }


        if (!isSelected) {
            if (b.getType() == 0) {
                setBackground(new Color(255, 204, 204));
            } else {
                setBackground(new Color(204, 255, 204));
            }

        } else {
            setBackground(Color.LIGHT_GRAY);
        }
        setOpaque(true);
        return this;
    }
}
